<!--分红订单明细-->
<template>
  <div>
    <f-search-form ref="search" :more="true" @searchHandler="searchHandler">
      <f-search-form-item label="回款日期" type="date"  name="endDate" style="width: 300px" />
      <f-search-form-item label="订单编号" name="orderNo" style="width: 250px" slot="advanced"/>
    </f-search-form>
    <f-table ref='table' rowKey='orderDetailsId' :showSetting='true' setting-key='bonus_tab1' :tableColumns='columns' :scroll='{x:true}' handler='noSettlePageListHandler' :showMultipleBtn='false' :operator='operator' :multiple='multiple' :params='queryParam' :api='api.bod'>
       <span slot='ownerState' slot-scope='text, record, index'>
            <a-tag color='#108ee9' v-if='text==0'>否</a-tag>
            <a-tag color='#f50' v-if='text==1'>是</a-tag>
       </span>
      <span slot='supplierBondType' slot-scope='text, record, index'>
            <a-tag color='#2db7f5' v-if='text==0'>不垫付</a-tag>
            <a-tag color='purple' v-if='text==1'>底价</a-tag>
            <a-tag color='purple' v-if='text==2'>底价+税金</a-tag>
            <a-tag color='purple' v-if='text==3'>税金</a-tag>
            <a-tag color='purple' v-if='text==6'>底价/2+税金</a-tag>
            <a-tag color='purple' v-if='text==5'>全额垫付</a-tag>
            <a-tag color='purple' v-if='text==8'>销售金额*费率</a-tag>
        </span>
      <span slot='customBondType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text==0'>全款</a-tag>
            <a-tag color='purple' v-if='text==1'>底价</a-tag>
            <a-tag color='purple' v-if='text==2'>底价+税金</a-tag>
            <a-tag color='purple' v-if='text==6'>底价/2+税金</a-tag>
            <a-tag color='purple' v-if='text==3'>税金</a-tag>
            <a-tag color='purple' v-if='text==5'>全额资信</a-tag>
            <a-tag color='purple' v-if='text==7'>预付款</a-tag>
        </span>
      <span slot='action' slot-scope='text, record'>
          <template>
            <a href='javascript:;' @click='settleSub(record)'>结算</a>
            <a-divider type='vertical' />
            <a @click='$refs.orderInfoDrawer.showDrawer(record)'>查看</a>
          </template>
        </span>
    </f-table>

  </div>
</template>
<script>
import api from "../../../js/api"

export default {
  name: "BonusInfoOrder",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),
      multiple: false,
      deptId: "",
      //列表初始化查询参数
      queryParam: {
        auth: 1
      },
      returnCustomBond: 0,
      selectIds: "",
      params1: {
        deptId: ""
      },
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "left",
          fixed: "left",
          customRender: (text, record, index) => index + 1
        }, 
        {
          title: "单据日期",
          align: "left",
          width: "100px",
          fixed: "left",
          dataIndex: "sendDate"
        },
        {
          title: "订单编号",
          align: "left",
          width: "130px",
          fixed: "left",
          dataIndex: "orderNo"
        },
        {
          title: "单位名称",
          align: "left",
          width: "100px",
          dataIndex: "deptName"
        },
        {
          title: "部门名称",
          align: "left",
          width: "100px",
          dataIndex: "deptName"
        },
        {
          title: "业务片区",
          align: "left",
          ellipsis: true,
          width: "180px",
          dataIndex: "customName"
        },
        {
          title: "结算区域",
          align: "left",
          width: "100px",
          dataIndex: "customBondType",
          scopedSlots: { customRender: "customBondType" }
        },
        {
          title: "业务员",
          align: "left",
          ellipsis: true,
          width: "180px",
          dataIndex: "customName"
        },
        {
          title: "商品类型",
          align: "left",
          ellipsis: true,
          width: "180px",
          dataIndex: "customName"
        },
        {
          title: "发货方式",
          align: "left",
          ellipsis: true,
          width: "180px",
          dataIndex: "customName"
        },
        {
          title: "商品名称",
          align: "left",
          ellipsis: true,
          width: "140px",
          dataIndex: "drugsName"
        },
        {
          title: "规格",
          align: "left",
          width: "80px",
          dataIndex: "drugsSpec"
        },
        {
          title: "件容",
          align: "left",
          width: "80px",
          dataIndex: "drugsSpec"
        },
        {
          title: "批号",
          align: "left",
          width: "80px",
          dataIndex: "drugLotNo"
        },
        {
          title: "销售单价",
          align: "left",
          width: "80px",
          dataIndex: "salePrice"
        },
        {
          title: "数量",
          align: "left",
          width: "80px",
          dataIndex: "saleNum"
        },
        {
          title: "销售金额",
          align: "left",
          width: "80px",
          dataIndex: "saleAmount"
        },
        {
          title: "回款金额",
          align: "left",
          width: "100px",
          dataIndex: "settleAmount2"
        }, {
          title: "回款日期",
          align: "left",
          width: "100px",
          dataIndex: "settleAmount3"
        }, {
          title: "件数",
          align: "left",
          width: "100px",
          dataIndex: "noSettleAmount"
        },
        {
          title: "成本价",
          align: "left",
          width: "80px",
          dataIndex: "returnAmount"
        },
        {
          title: "成本金额",
          align: "left",
          width: "120px",
          dataIndex: "returnDate"
        },
        {
          title: "统一结算价",
          align: "left",
          width: "90px",
          dataIndex: "settleAmount"
        },
        {
          title: "返利政策",
          align: "left",
          width: "90px",
          dataIndex: "settleAmount"
        },
        {
          title: "税率",
          align: "left",
          width: "90px",
          dataIndex: "settleAmount"
        },
        {
          title: "已付费用",
          align: "left",
          width: "90px",
          dataIndex: "settleAmount"
        },
        {
          title: "部门结算价",
          align: "left",
          width: "90px",
          dataIndex: "settleAmount"
        },
        {
          title: "税率",
          align: "left",
          width: "90px",
          dataIndex: "settleAmount"
        }, {
          title: "税率差",
          align: "left",
          width: "90px",
          dataIndex: "settleAmount"
        },
        {
          title: "部门利润",
          align: "left",
          width: "90px",
          fixed: "right",
          dataIndex: "settleAmount"
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    setData() {
    },
    settleSub(record) {
      let orderDetailsId = record.orderDetailsId
      let settleAmount = record.noSettleAmount
      let settleAmount2 = record.noSettleAmount2
      if (record.jiesuanId) {
        settleAmount = 0
      }
      if (record.jiesuanId2 && record.jiesuanId2 != "") {
        settleAmount2 = 0
      }
      this.$refs["settleDrawer"].showDrawer({
        settleAmount: settleAmount,
        settleAmount2: settleAmount2,
        orderDetailsId: orderDetailsId,
        orderId: record.orderId,
        deptId: record.deptId
      }, "form1")
    },
    //部门切换
    deptChange(value) {
      this.queryParam.deptId = value
      this.$refs.table.refresh(false)
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    },
    openMultiple(searchParams) {
      if (searchParams.deptId) {
        this.multiple = true
        this.deptId = searchParams.deptId
      }
    },
    /**
     * 刷新列表
     */
    onLoad() {
      this.$refs.table.refresh()
      this.$emit("changeTab")
    }
  }
}
</script>